package com.android.JiYclock.shareAlarm;

import java.util.Calendar;

import com.android.JiYclock.AlarmClock;
import com.android.JiYclock.Log;
import com.android.JiYclock.R;
import com.android.JiYclocks.SpecialAlarm;
import com.android.JiYclocks.SpecialAlarms;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;


public class NewSmsDialog extends Activity {
	
	private Button buttonSure = null;
	private Button buttonDismiss = null;
	private TextView shareAlertWhereValue = null;
	private String templocation = null;
	private Long temptime =null; 
	private Calendar  calendar ;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.newsmsdialog);
		initLayout();
		shareAlertWhereValue.setText(smsUtility.getAddress(this));
		calendar = Calendar.getInstance();
		calendar.setTimeInMillis(temptime);
		buttonSure.setOnClickListener(new buttonSureListener());
		buttonDismiss.setOnClickListener(new buttonDismissListener());
		
	}

	public void initLayout()
	{
		buttonSure = (Button)findViewById(R.id.sure);
		
		buttonDismiss = (Button)findViewById(R.id.dismiss);
		
		shareAlertWhereValue = (TextView)findViewById(R.id.shareAlertWhereValue);
		
		setTemplocation(String.valueOf(smsUtility.getAlarmUri(this)));
		
		setTemptime(Long.parseLong(smsUtility.getAlarmTime(this)));
		
	}

class buttonSureListener implements OnClickListener
   {

	@Override
	public void onClick(View v) {
		//利用获取到的数据，来建立一个新的闹钟，同时返回到主界面
		SpecialAlarm specialalarm = new SpecialAlarm(templocation,calendar);
		SpecialAlarms.addAlarm(NewSmsDialog.this, specialalarm);
		Intent intent = new Intent(NewSmsDialog.this,AlarmClock.class);
		startActivity(intent);
		
	}
	   
   }
   
   class buttonDismissListener implements OnClickListener
   {

	@Override
	public void onClick(View v) {
		
		//用户选择取消，则返回到主页面去
		Intent intent = new Intent(NewSmsDialog.this,AlarmClock.class);
		startActivity(intent);
		
	}
	   
   }
   
   public void setTemplocation(String templocation) {
		this.templocation = templocation;
	}

	public String getTemplocation() {
		return templocation;
	}

public void setTemptime(Long temptime) {
		this.temptime = temptime;
	}

	public Long getTemptime() {
		return temptime;
	}
	
	
	}

